<template>
  <div class="doread_detail">
    <van-nav-bar class="navBar" :title="contentForm.pendingTypeName" left-arrow @click-left="onClickLeft" />
    <div class="content">
      <van-panel>
        <template #header>
          <div class="title">
            <img src="./img/icon_shgd.png" alt="" width="20" height="20" />
            {{ contentForm.pendingTypeId == '10' ? contentForm.orderType == '1' ? '包区绑定人员失效提醒' : '目标市场绑定人员失效提醒' : contentForm.orderTitle }}
          </div>
          <div :class="contentForm.state == 1 ? 'status1' : 'status0'">工单当前状态：{{ contentForm.stateName }}</div>
          <van-divider class="line" />
        </template>
        <div class="form" v-for="(item, index) in contentList" :key="index">
          <div class="form_title">{{ item.title }}</div>
          <div v-if="item.key == 'yyrw'">
            <table class="cxrw_table">
              <thead>
                <tr>
                  <th>邀约任务名称</th>
                  <th>邀约用户</th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="(item, index) in formMission" :key="index">
                  <td>{{ item.invitationTaskName }}</td>
                  <td>{{ item.invitationUser }}</td>
                </tr>
              </tbody>
            </table>
          </div>
          <div v-if="item.key == 'sltzrw'">
            <table class="cxrw_table">
              <thead>
                <tr>
                  <th>接单人</th>
                  <th>接单量</th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="(item, index) in fourTypesList" :key="index">
                  <td>{{ item.executeName }}</td>
                  <td>{{ item.orderNum }}</td>
                </tr>
              </tbody>
            </table>
          </div>
          <div v-else-if="item.key == 'hfyyyh'">
            <div class="user">
              <div class="content">
                <div class="label">活动用户</div>
                <div class="value">{{ contentForm.activeUsers || 0 }}</div>
              </div>
              <div class="content">
                <div class="label">待回访</div>
                <div class="value">{{ contentForm.pendingFollowUp || 0 }}</div>
              </div>
              <div class="content">
                <div class="label">已回访</div>
                <div class="value">{{ contentForm.followUp || 0 }}</div>
              </div>
              <div class="content">
                <div class="label">有意向</div>
                <div class="value">{{ contentForm.intentional || 0 }}</div>
              </div>
              <div class="content">
                <div class="label">已受理</div>
                <div class="value">{{ contentForm.accepted || 0 }}</div>
              </div>
            </div>
          </div>
          <div v-else-if="item.key == 'spls' && (contentForm.pendingTypeId == '1' || contentForm.pendingTypeId == '9') && contentForm.sourceSystemId == '1'">
            <a-table style="margin: 10px 0 0 0" :columns="tableColumn" :data-source="tableData" bordered
              :pagination="false">
              <span slot="xh" slot-scope="text, record, index">{{ index + 1 }}</span>
            </a-table>
          </div>
          <div v-else-if="item.key.includes('Rybd')">
            <a-table style="margin: 10px 0 0 0" :columns="contentForm.orderType == '1' ? tableColumnBq : tableColumnMbsc" :data-source="tableData" bordered
              :pagination="false">
              <span slot="xuhao" slot-scope="text, record, index">{{ index + 1 }}</span>
            </a-table>
          </div>
          <div v-else-if="item.key == 'onSitePhotos'" class="img_box">
            <div v-for="(items, indexs) in gwzdPhotos" :key="indexs">
              <img :src="items" alt="" srcset="" width="50" height="50"
                @click="handlePreviewTd('gwzdPhotos', indexs)" />
            </div>
          </div>
          <div v-else>
            <div :class="its.class && (contentForm.suggestSelect !== '1'|| !contentForm.engineerChoosesExpansionMethod || contentForm.operationType == '0' ) ? 'form_content_remark' : 'form_content'" v-for="(its, inds) in item.children"
              :key="inds">
              <div :class="(its.type == 'remark' && contentForm.engineerChoosesExpansionMethod && contentForm.operationType !== '0')||(its.type == 'radio' && contentForm.engineerChoosesExpansionMethod && contentForm.operationType !== '0')
                ? 'label_required'
                : 'label'
                ">
                {{ its.type == 'remark' && (classifyType == '9' || classifyType == '1') && contentForm.engineerChoosesExpansionMethod && contentForm.operationType !== '0'? '原因' :its.label }}
              </div>
              
              <div :class="its.class ? 'value_detail' : 'value'">
                <div class="" v-if="its.type == 'remark' && (classifyType !== '9' && classifyType !== '1') ">
                    <a-textarea  v-model="contentForm.suggest" placeholder="请输入审批留言" allow-clear
                  :disabled="active == '1' || active == '5'" :class="{ 'ant-input-errors': showError && isTouched }"
                  @input="handleInputRemark" @blur="handleBlurRemark" />
                  <div v-if="showError && isTouched && its.type == 'remark'" class="error-message">请输入审批留言!</div>
                </div>
               
                <!-- 原因选择 -->
                <div v-else-if="its.type == 'remark' && (classifyType == '9' || classifyType == '1')" >
                  <div class="sply" v-if="contentForm.operationType == '0'">
                    <a-textarea  v-model="contentForm.suggest" placeholder="请输入审批留言" allow-clear
                  :disabled="active == '1' || active == '5'" :class="{ 'ant-input-errors': showError && isTouched }"
                  @input="handleInputRemark" @blur="handleBlurRemark" />
                    <div v-if="showError && isTouched && its.type == 'remark'" class="error-message">请输入审批留言!</div>
                  </div>
                  
                 <div class="selectClass" v-else>
                  <van-cell is-link :title=" contentForm.suggest ? contentForm.suggest : '请选择' " @click="showSelect = true" />
                  <div v-if="showError && its.type == 'remark' && !contentForm.suggest " class="error-message">请选择原因!</div>
                 </div>
               </div>
                <a-input v-else-if="its.type == 'input'" v-model="contentForm[its.key]" :placeholder="'请输入' + its.label"
                  allow-clear :disabled="active == '1' || active == '5'" />
                <div v-else-if="its.type == 'imgs'">
                  <div v-if="its.key == 'gsPhoto'" class="img_box">
                    <div v-for="(items, indexs) in gsPhotos" :key="indexs">
                      <img :src="items" alt="" srcset="" width="50" height="50"
                        @click="handlePreviewTd('gsPhotos', indexs)" />
                    </div>
                  </div>
                  <div v-else-if="its.key == 'csPhoto'" class="img_box">
                    <div v-for="(items, indexs) in csPhotos" :key="indexs">
                      <img :src="items" alt="" srcset="" width="50" height="50"
                        @click="handlePreviewTd('csPhotos', indexs)" />
                    </div>
                  </div>
                  <div v-else-if="its.key == 'dyPhoto'" class="img_box">
                    <div v-for="(items, indexs) in dyPhotos" :key="indexs">
                      <img :src="items" alt="" srcset="" width="50" height="50"
                        @click="handlePreviewTd('dyPhotos', indexs)" />
                    </div>
                  </div>
                  <div v-else-if="its.key == 'gmPhoto'" class="img_box">
                    <div v-for="(items, indexs) in gmPhotos" :key="indexs">
                      <img :src="items" alt="" srcset="" width="50" height="50"
                        @click="handlePreviewTd('gmPhotos', indexs)" />
                    </div>
                  </div>
                  <div v-else>
                    <div v-for="(items, indexs) in checkinPhotos" :key="indexs">
                      <img :src="items.photo" alt="" srcset="" width="50" height="50"
                        @click="handlePreview(items, indexs)" />
                    </div>
                  </div>
                </div>
                <van-radio-group v-else-if="its.type == 'radio' && !contentForm.engineerChoosesExpansionMethod" v-model="contentForm.operationType"
                  :disabled="active == '1' || active == '5'">
                  <van-radio name="1" checked-color="#41c2bf">
                    {{ contentForm.engineerChoosesExpansionMethod ? '继续退单' : '通过' }}
                  </van-radio>
                  <van-radio name="0" checked-color="#41c2bf">{{
                    contentForm.engineerChoosesExpansionMethod ? '同意快扩' : '不通过'
                  }}</van-radio>
                </van-radio-group>
                <div class="radio_Box" v-else-if="its.type == 'radio' && contentForm.engineerChoosesExpansionMethod">
                  <van-radio-group v-model="contentForm.operationType" :disabled="active == '1' || active == '5'" @change="changeState">
                    <van-radio name="1" checked-color="#41c2bf" >
                      {{ contentForm.engineerChoosesExpansionMethod ? '继续退单' : '通过' }}
                    </van-radio>
                    <van-radio name="0" checked-color="#41c2bf" style="margin:0 8px;">{{
                      contentForm.engineerChoosesExpansionMethod ? '同意快扩' : '不通过'
                      }}</van-radio>
                    <van-radio name="3" v-if="contentForm.engineerChoosesExpansionMethod" checked-color="#41c2bf">
                      退回给工程师
                    </van-radio>
                  </van-radio-group>
                </div>

                <div v-else>{{ contentForm[its.key] }}</div>
              </div>
            </div>
          </div>
        </div>
        <div class="pj">
          <div class="form_title">随单评价</div>
          <div class="form_content">
            <div class="label">满意度评价</div>
            <div class="value">
              <van-rate v-model="forms.value" :size="25" color="#ffd21e" void-icon="star" void-color="#eee" :readonly="active == '1' || active == '5'" />
            </div>
          </div>
          <div class="form_content_remark" v-if="forms.value <= forms.threshold">
            <div class="label_required">不满意度原因</div>
            <div class="value_detail">
              <a-form-model ref="ruleForm" :model="forms">
                <a-form-model-item prop="reason" :rules="[
                  {
                    required: true,
                    message: '请输入不满意度原因内容且不少于15字！',
                    trigger: ['blur', 'change'],
                    validator: (rule, values) => values.length > 15,
                  },
                ]">
                  <a-textarea v-model="forms.reason" placeholder="请输入不满意度原因" allow-clear
                    :disabled="active == '1' || active == '5'" />
                </a-form-model-item>
              </a-form-model>
            </div>
          </div>
        </div>
        <template #footer>
          <van-button @click="onClickLeft">关闭</van-button>
          <div v-if="contentForm.state == '0' && classifyType == 5"
            style="width: 150%; display: flex; justify-content: space-between">
            <van-button plain type="info" @click="handleDispatch">转派</van-button>
            <van-button type="info" :loading="loadingBtn" @click="onSubmit">提交</van-button>
          </div> 
          <div v-else-if="contentForm.gqFlag == '1'"
            style="width: 150%; display: flex; justify-content: space-between">
            <van-button plain type="info" :loading="loadingBtnUp" @click="onSubmit('up')">挂起</van-button>
            <van-button type="info" :loading="loadingBtn" @click="onSubmit('')">提交</van-button>
          </div>
          <van-button v-else-if="contentForm.state == '0' && classifyType == 6 && contentForm.operationType == '1'"
            type="info" @click="handleDispatchTdcp">转派</van-button>
          <van-button v-else-if="
            (contentForm.state == '0' && classifyType !== 6) ||
            (classifyType == 6 && contentForm.operationType == '0')
          " type="info" :loading="loadingBtn" @click="onSubmit('')">提交</van-button>
        </template>
      </van-panel>
    </div>
    <van-action-sheet  v-model="showSelect" title="选择原因类型">
      <div class="reasonRadio">
        <van-radio-group  v-model="selectReason"  :disabled="active == '1' || active == '5'">
          <van-cell-group @change="changeReason">
            <van-cell :title="item.title" clickable v-for="(item,indx) in reasonList" :key="indx">
              <template #right-icon>
                <van-radio :name="item.value" />
              </template>
            </van-cell>
          </van-cell-group>
        </van-radio-group>
      </div>
      <van-button type="info" size="large" @click="onSubmitReason">确定</van-button>
    </van-action-sheet>
    <van-dialog
      v-model="showTip"
      :showConfirmButton="false"
    >
      <div class="showContent">
        <van-icon name="passed" class="iconStyle"/>
        <p class="pcontent">提交成功</p>
        <p><span>请在<span class="tipSuccess">小CEO工作台PC端>辅助管理>人员绑定管理</span>页面操作</span></p>
        <van-button class="btnStyle" round type="info" @click="cancleBtn">关闭</van-button>
      </div>
    </van-dialog>
    <van-popup v-model="showGrid" round position="bottom">
      <dialogGrid ref="dialogGridRef" :content="contentForm" @reload="searchQuery"></dialogGrid>
    </van-popup>
    <van-popup v-model="showPerson" round position="bottom">
      <dialogPerson ref="dialogPersonRef" :content="contentForm" @reload="searchQuery"></dialogPerson>
    </van-popup>
  </div>
</template>

<script>
import {
  dbgdDetail,
  dbgdZykrListDetail,
  dbgdZykrDetail,
  cxrwDetail,
  cxzxDetail,
  bmdzDetail,
  bzdzDetail,
  tdcpDetail,
  sbgdDetail,
  gscg,
  cscg,
  dycg,
  gmcg,
  tableColumn,
  cxrwSltzrwDetail,
  gwzdDetail,
  rybdDetailBq,
  rybdDetailMbsc,
  tableColumnBq,
  tableColumnMbsc,
  yjyyThgcs,
  yjyyJxtd
} from './common'
import {
  promotionTasks,
  promotionExecution,
  refundReview,
  submitUrl,
  bmdzForm,
  bzdzForm,
  refundApprove,
  rybdDetailUrl,
  rybdDetailList
} from '@/api/publicline/todoread.js'
import { sql2apiAction, postAction } from '@/api/manage'

import { Toast, ImagePreview } from 'vant'
import dialogGrid from './dialogGrid.vue'
import dialogPerson from './dialogPerson.vue'

export default {
  name: 'todoToreadDetail',
  components: { dialogGrid, dialogPerson },

  data() {
    return {
      tableColumn,
      tableColumnBq,
      tableColumnMbsc,
      yjyyJxtd,
      yjyyThgcs,
      tableData: [],
      id: '',
      loading: false,
      loadingBtn: false,
      loadingBtnUp: false,
      active: '',
      classifyType: '',
      contentList: [],
      contentForm: {
        operationType: '1',
        suggest: '',
      },
      formMission: [],
      checkinPhotos: [],
      showGrid: false,
      showPerson: false,
      gsPhotos: [],
      csPhotos: [],
      dyPhotos: [],
      gmPhotos: [],
      forms: { reason: '', value: 0, threshold: 0 },
      evaluationObj: {},
      fourTypesList: [],
      gwzdPhotos: [],
      isTouched: false, // 是否已经触碰过输入框
      showTip: false,
      showSelect: false,
      selectReason: '',
      reasonList:[]
    }
  },
  computed: {
    showError() {
      return (this.contentForm.suggest.trim() == '' && (this.contentForm.engineerChoosesExpansionMethod) && (this.contentForm.operationType == '0' ? false : true));
    },
  },
  mounted() {
    this.id = this.$route.params.id
    this.active = this.$route.params.state
    this.classifyType = sessionStorage.getItem('classifyType')
    this.getEvaluation(this.id)
    this.getDetail()
  },
  methods: {
    onClickLeft() {
      this.$router.push({
        path: '/publicline/todoToread',
      })
      sessionStorage.removeItem('classifyType')
      this.forms = {
        reason: '',
        value: 0,
        threshold: 0,
      }
      if (this.$refs['ruleForm']) {
        this.$refs['ruleForm'].resetFields()
      }
    },
    handleInputRemark() {
      // 实时校验，但只在用户首次交互后显示错误
      if (this.isTouched) {
        this.$nextTick(() => {
          // 可以在这里添加额外的处理逻辑
        });
      }
    },
    handleBlurRemark() {
      if (this.contentForm.engineerChoosesExpansionMethod && this.contentForm.suggest.trim() == '') {
        this.isTouched = true;
      } else {
        this.isTouched = false;
      }
    },
    changeState(v){
      this.reasonList = v == '1' ? yjyyJxtd : yjyyThgcs
      this.contentForm.suggest = ''
    },
    changeReason(v){
      this.selectReason = v
    },
    showSelectReason(v){
      this.showSelect = true
    },
    onSubmitReason(){
      this.showSelect = false
      this.contentForm.suggest = this.selectReason
    },
    getDetail() {
      switch (this.classifyType) {
        case '1':
          this.getRefundReview()
          break
        case '2':
          this.getPromotionTasks()
          this.getMissionsOrImgs()
          this.getFourTypes(this.id)
          break
        case '3':
          this.getPromotionExecution()
          this.getMissionsOrImgs()
          break
        case '4':
          this.getBzdzData()
          break
        case '5':
          this.getBmdzData()
          break
        case '6':
          this.getTdcpData()
          break
        case '7':
          this.getSbgdData()
          this.getSbgdImgs()
          break
        case '8':
          this.getGwzdData()
          break
        case '9':
          this.getRefundReview()
          break
        case '10':
          this.getRybd()
          break
      }
    },
    getEvaluation(ids) {
      postAction('/api/order/getEvaluateConf', { id: ids })
        .then((res) => {
          if (res.code == 1) {
            this.evaluationObj = { ...res.data } || {}
            if (this.active == '1') {
              if (this.evaluationObj.tempConf.length > 0) {
                if (this.evaluationObj.tempConf[0].max == 10) {
                  this.forms.value = this.evaluationObj.tempConf[0].value
                    ? Number(this.evaluationObj.tempConf[0].value) / 2
                    : 0
                  this.forms.threshold = this.evaluationObj.tempConf[0].threshold
                    ? Number(this.evaluationObj.tempConf[0].threshold) / 2
                    : 0
                } else {
                  this.forms.value = this.evaluationObj.tempConf[0].value
                    ? Number(this.evaluationObj.tempConf[0].value)
                    : 0
                  this.forms.threshold = this.evaluationObj.tempConf[0].threshold
                    ? Number(this.evaluationObj.tempConf[0].threshold)
                    : 0
                }
              }
            } else {
              this.forms.value = Number(this.evaluationObj.tempConf[0].max) || 0
              this.forms.threshold = this.evaluationObj.tempConf[0].threshold
                ? Number(this.evaluationObj.tempConf[0].threshold)
                : 0
            }
            this.forms.reason = this.evaluationObj.tempConf[0].reason || ''
          } else {
            this.evaluationObj = {
              tempConf: []
            }
            this.evaluationObj.tempConf.push({
              max: 5,
              threshold: 4,
              reason: '',
            })
            this.forms.value = Number(this.evaluationObj.tempConf[0].max)
            this.forms.threshold = this.evaluationObj.tempConf[0].threshold
              ? Number(this.evaluationObj.tempConf[0].threshold)
              : 0
            this.forms.reason = this.evaluationObj.tempConf[0].reason || ''
          }
        })
        .catch((err) => {
          console.log('🚀 ~ getJudgeData ~ err:', err)
          this.evaluationObj = {
            tempConf: []
          }
          this.evaluationObj.tempConf.push({
            max: 5,
            threshold: 4,
            reason: '',
          })

          this.forms.value = Number(this.evaluationObj.tempConf[0].max)
            this.forms.threshold = this.evaluationObj.tempConf[0].threshold
              ? Number(this.evaluationObj.tempConf[0].threshold)
              : 0
            this.forms.reason = this.evaluationObj.tempConf[0].reason || ''
        })
    },
    getMissionsOrImgs() {
      let types = {
        2: '2c3ae8ab90481d740190482ce91c0002',
        3: '2c3ae8ab90481d74019048318a5e0003', //照片
      }
      sql2apiAction(types[this.classifyType], { id: this.id })
        .then((res) => {
          this.formMission = res.result || []
          this.checkinPhotos = res.result || []
        })
        .catch((err) => { })
    },
    getSbgdImgs() {
      postAction('api/order/getSLTZDSBPhotoInfo', { id: this.id })
        .then((res) => {
          this.csPhotos = res.data.cs || []
          this.dyPhotos = res.data.dy || []
          this.gmPhotos = res.data.gm || []
          this.gsPhotos = res.data.gs || []
        })
        .catch((err) => { })
    },
    handlePreview(item, index) {
      let urlList = this.checkinPhotos.map((item) => {
        // return `${window.webConfig.api}/oss-api-service/attachment/download/${item}/`
        return item.photo
      })
      ImagePreview({
        images: urlList,
        startPosition: index,
      })
    },
    handlePreviewTd(list, index) {
      let urlList = this[list].map((item) => {
        // return `${window.webConfig.api}/oss-api-service/attachment/download/${item}/`
        return item
      })
      ImagePreview({
        images: urlList,
        startPosition: index,
      })
    },
    getPromotionTasks() {
      this.contentList = cxrwDetail

      promotionTasks({ id: this.id }).then((res) => {
        this.loading = false
        if (res.result) {
          if (res.result[0].state == '0') {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
          } else {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
          }
        }
      })
    },
    getPromotionExecution() {
      this.contentList = cxzxDetail

      promotionExecution({ id: this.id }).then((res) => {
        this.loading = false
        if (res.result) {
          if (res.result[0].state == '0') {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
          } else {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
          }
        }
      })
    },
    getApproveList() {
      refundApprove({ id: this.id }).then((res) => {
        this.loading = false
        if (res.result) {
          this.tableData = res.result || []

          this.contentList = this.tableData.length > 0 ? dbgdZykrListDetail : dbgdZykrDetail
        }
      }).catch((err) => {
        console.log("🚀 ~ refundApprove ~ err:", err)
      })
    },
    getFourTypes(ids) {
      sql2apiAction('2c3ae8af92b81400019535e0219f0004', { id: ids })
        .then((res) => {
          this.fourTypesList = res.result || []
          if (this.fourTypesList.length > 0) {
            this.contentList = cxrwSltzrwDetail
          }
        })
        .catch((err) => {
          console.log('🚀 ~ getFourTypes ~ err:', err)
        })
    },
    getRybd() {
      this.contentList = rybdDetailBq
      rybdDetailUrl({ id: this.id }).then((res) => {
        this.loading = false
        if (res.result) {
          if (res.result[0].state == '0') {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
            this.contentForm.operationType = this.contentForm.engineerChoosesExpansionMethod && res.result[0].operationType == '1' ? '1' : '0'
          } else {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
          }
          if(this.contentForm.orderType == '1'){
            this.contentList = rybdDetailBq
          }else{
            this.contentList = rybdDetailMbsc

          }
          this.getRybdList()
        }
      })
    },
    getRybdList() {
      rybdDetailList({ id: this.id }).then((res) => {
        this.loading = false
        if (res.result) {
          this.tableData = res.result || []
        }
      }).catch((err) => {
        console.log("🚀 ~ refundApprove ~ err:", err)
      })
    },
    getRefundReview() {
      this.contentList = dbgdDetail
      refundReview({ id: this.id }).then((res) => {
        this.loading = false
        if (res.result) {
          if (res.result[0].state == '0') {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
            this.contentForm.operationType = this.contentForm.engineerChoosesExpansionMethod && res.result[0].operationType == '1' ? '1' : '0'
            this.selectReason = this.contentForm.operationType !=='0'? this.contentForm.suggest : ''
          } else {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
            this.selectReason = this.contentForm.operationType !=='0'? this.contentForm.suggest : ''
          }
          if (this.contentForm.engineerChoosesExpansionMethod) {
            this.contentList = dbgdZykrDetail
          }
          if((this.contentForm.pendingTypeId == '1' || this.contentForm.pendingTypeId == '9') && this.contentForm.sourceSystemId == '1'){
            this.getApproveList()
          }
        }
      })
    },
    getBzdzData() {
      this.contentList = bzdzDetail
      bzdzForm({ id: this.id }).then((res) => {
        this.loading = false
        if (res.result) {
          if (res.result[0].state == '0') {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
          } else {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
          }
        }
      })
    },
    getBmdzData() {
      this.contentList = bmdzDetail
      bmdzForm({ id: this.id }).then((res) => {
        this.loading = false
        if (res.result) {
          if (res.result[0].state == '0') {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
          } else {
            this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
          }
        }
      })
    },
    getTdcpData() {
      this.contentList = tdcpDetail
      sql2apiAction('2c3ae8ab90481d740190729f85c60005', { id: this.id })
        .then((res) => {
          this.loading = false
          if (res.result) {
            if (res.result[0].state == '0') {
              this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
            } else {
              this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
            }
          }
        })
        .catch((err) => { })
    },
    getSbgdData() {
      this.contentList = sbgdDetail
      sql2apiAction('2c3ae8ab90481d74019072a9fc620006', { id: this.id })
        .then((res) => {
          this.loading = false
          if (res.result) {
            if (res.result[0].state == '0') {
              this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
            } else {
              this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
            }
            //
            let formItem = JSON.parse(JSON.stringify(sbgdDetail))
            if (this.contentForm.gsResultId == 1) {
              formItem[2].children = gscg
              this.contentList = formItem
            }
            if (this.contentForm.csResultId == 1) {
              formItem[3].children = cscg
              this.contentList = formItem
            }
            if (this.contentForm.dyResultId == 1) {
              formItem[4].children = dycg
              this.contentList = formItem
            }
            if (this.contentForm.gmResultId == 1) {
              formItem[5].children = gmcg
              this.contentList = formItem
            }
          }
        })
        .catch((err) => { })
    },
    getGwzdData() {
      this.contentList = gwzdDetail
      sql2apiAction('2c3ae8af92b8140001956063ab940005', { id: this.id })
        .then((res) => {
          this.loading = false
          if (res.result) {
            if (res.result[0].state == '0') {
              this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
            } else {
              this.contentForm = { ...this.contentForm, ...(res.result[0] || {}) }
            }
            this.gwzdPhotos.push(this.contentForm.onSitePhotos)
          }
        })
        .catch((err) => { })
    },
    handleDispatch() {
      this.showGrid = true
    },
    handleDispatchTdcp() {
      this.showPerson = true
    },
    onSubmit(type) {
      let params = {
        orderId: this.id,
        operationType: this.contentForm.operationType,
        suggest: this.contentForm.suggest,
      }
      if (this.contentForm.pendingTypeId == 5) {
        params.updateField = this.contentForm.newAliasAddress || ''
      }
      this.evaluationObj.tempConf[0].value =
        this.evaluationObj.tempConf[0].max == 10 ? this.forms.value / 2 || 0 : this.forms.value || 0
      this.evaluationObj.tempConf[0].reason =
        this.evaluationObj.tempConf[0].max == this.forms.value ? '' : this.forms.reason || ''
      params = { ...params, satisfactionSurveysTemplateEntity: { ...this.evaluationObj } }
      if (this.showError) {
        this.isTouched = true
      }
      if (this.forms.value <= this.forms.threshold) {
        this.$refs.ruleForm.validate((valid) => {
          if (valid && !this.showError) {
            if(type){
              this.submitParamsUp(params)
            }else{
              this.submitParams(params)
            }
          }
        })
      } else {
        if (!this.showError) {
          if(type){
            this.submitParamsUp(params)
          }else{
            this.submitParams(params)
          }
        }
      }
    },
    cancleBtn(){
      this.showTip = false
      this.loadingBtn = false
      this.$router.push({
        path: '/publicline/todoToread',
      })
      sessionStorage.removeItem('classifyType')
    },
    submitParams(params) {
      this.loadingBtn = true
      submitUrl({ ...params })
        .then((res) => {
          if (res.code == 1) {
            if(this.contentForm.pendingTypeId == '10'){
              this.showTip = true
            }else{
              this.loadingBtn = false
              this.$router.push({
                path: '/publicline/todoToread',
              })
              sessionStorage.removeItem('classifyType')
              Toast.success(res.message)
            }
          } else {
            Toast.fail(res.message)
          }
        })
        .catch((err) => {
          this.loadingBtn = false
          Toast.fail(err.message)
        })
        .finally(() => {
          this.loadingBtn = false
        })
    },
    submitParamsUp(params) {
      this.loadingBtnUp = true
      params.operationType = '6'
      submitUrl({ ...params })
        .then((res) => {
          if (res.code == 1) {
            this.loadingBtnUp = false
            this.$router.push({
              path: '/publicline/todoToread',
            })
            sessionStorage.removeItem('classifyType')
            Toast.success(res.message)
          } else {
            Toast.fail(res.message)
          }
        })
        .catch((err) => {
          this.loadingBtnUp = false
          Toast.fail(err.message)
        })
        .finally(() => {
          this.loadingBtnUp = false
        })
    },
    searchQuery() {
      this.loadingBtn = false
      this.$router.push({
        path: '/publicline/todoToread',
      })
      sessionStorage.removeItem('classifyType')
      Toast.success('转派成功')
    },
  },
}
</script>
<style lang="less" scoped>
.doread_detail {
  // overflow: hidden;
  background: #fff;
  position: relative;

  .navBar {
    position: fixed;
    width: 100%;
    top: 0px;
  }

  .content {
    // margin-top: 46px;
    // height: calc(100vh - 46px);
    // overflow-y: auto;
    padding-bottom: 46px;
  }

  .title {
    padding: 20px 10px 10px;
    font-size: 18px;
    color: #333333;
    font-weight: bold;
    font-family: PingFangSC-Semibold;
  }

  .status0 {
    width: 42%;
    font-family: PingFangSC-Regular;
    font-size: 14px;
    color: #6e79fd;
    margin-left: 30px;
    background: rgba(110, 121, 253, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
  }

  .status1 {
    width: 42%;
    font-family: PingFangSC-Regular;
    font-size: 14px;
    color: #41c2bf;
    margin-left: 30px;
    background: rgba(65, 194, 191, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
  }

  .line {
    padding: 0 10px;
  }

  .form {
    .form_title {
      font-family: PingFangSC-Regular;
      margin-left: 20px;
      font-size: 16px;
      color: #000000;
      position: relative;
      margin-top: 10px;
    }

    .form_title::before {
      content: '';
      width: 4px;
      height: 18px;
      position: absolute;
      top: 3px;
      left: -10px;
      background-color: #4d98ff;
      border: 1px solid #4d98ff;
      border-radius: 20px;
    }

    .form_content {
      display: flex;
      padding: 10px 10px 0;
      border-bottom: 1px solid #e6e6e6;
      justify-content: space-between;
      font-size: 14px;

      .label {
        color: #333333;
        padding-left: 10px;
      }

      .value {
        color: #999999;
        padding-right: 10px;
        padding-bottom: 10px;
        max-width: 180px;
        // white-space: pre-wrap;
        word-break: break-all;
      }
      .valuePj {
        color: #999999;
        padding-right: 10px;
        padding-bottom: 10px;
        max-width: 84%;
        // white-space: pre-wrap;
        // word-break: break-all;
      }
      .label_required {
        color: #333333;
        padding-left: 10px;
        margin-bottom: 10px;
      }

      .label_required::after {
        content: '*';
        font-size: 14px;
        color: #fd806e;
        display: inline-block;
        margin-left: 4px;
      }
    }

    .form_content_remark {
      padding: 10px 10px 0;
      font-size: 14px;
      // border-bottom: 1px solid #e6e6e6;

      .label {
        color: #333333;
        padding-left: 10px;
        margin-bottom: 10px;
      }

      .label_required {
        color: #333333;
        padding-left: 10px;
        margin-bottom: 10px;
      }

      .label_required::after {
        content: '*';
        font-size: 14px;
        color: #fd806e;
        display: inline-block;
        margin-left: 4px;
      }
    }

    .img_box {
      display: flex;
      flex-wrap: wrap;
      padding-left: 10px;

      div {
        margin-left: 10px;
        margin-bottom: 10px;
      }
    }

    .user {
      padding-top: 10px;
      display: flex;
      background: #f6fbff;
      justify-content: center;

      // margin: 10px auto;
      .content {
        margin-left: 2px;
        padding: 0 4px;
        font-size: 15px;
        text-align: center;
        border-right: 1px solid #e6e6e6;
        width: calc(20% - 5px);

        .label {}

        .value {
          // text-align: center;
          font-size: 16px;
          font-weight: bold;
        }
      }

      .content:last-child {
        border: 0px;
      }
    }

    .cxrw_table {
      width: 90%;
      margin-left: 20px;
      background: #f8fbff;
      font-size: 14px;
      font-weight: normal;

      thead {
        tr {
          th {
            color: #929397;
            border: 1px solid #f5f5f5;
            font-weight: normal;
          }

          th:first-child {
            width: 70%;
          }
        }
      }

      tbody {
        tr {
          td {
            color: #333333;
            border: 1px solid #f5f5f5;
          }
        }
      }
    }

    .radio_Box {
      /deep/ .van-radio-group {
        display: flex;
        justify-content: space-between;
        width: 100%;
      }
    }
  }

  .pj {
    .form_title {
      font-family: PingFangSC-Regular;
      margin-left: 20px;
      font-size: 16px;
      color: #000000;
      position: relative;
      margin-top: 10px;
    }

    .form_title::before {
      content: '';
      width: 4px;
      height: 18px;
      position: absolute;
      top: 3px;
      left: -10px;
      background-color: #4d98ff;
      border: 1px solid #4d98ff;
      border-radius: 20px;
    }

    .form_content {
      display: flex;
      padding: 10px 10px 0;
      border-bottom: 1px solid #e6e6e6;
      justify-content: space-between;
      font-size: 14px;

      .label {
        color: #333333;
        padding-left: 10px;
      }

      .value {
        color: #999999;
        padding-right: 10px;
        padding-bottom: 10px;
        max-width: 180px;
        // white-space: pre-wrap;
        word-break: break-all;
      }
    }

    .form_content_remark {
      padding: 10px 10px 0;
      font-size: 14px;
      border-bottom: 1px solid #e6e6e6;

      .label {
        color: #333333;
        padding-left: 10px;
        margin-bottom: 10px;
      }

      .label_required {
        color: #333333;
        padding-left: 10px;
        margin-bottom: 10px;
      }

      .label_required::after {
        content: '*';
        font-size: 14px;
        color: #fd806e;
        display: inline-block;
        margin-left: 4px;
      }
    }
  }
}

/deep/ .van-nav-bar__content {
  background: linear-gradient(134deg, #80d9f9 0%, #5466fa 100%);
}

/deep/ .van-cell {
  padding: 0px;
  color: #a0a0a0;
}
/deep/ .van-panel {
  margin-top: 46px;
  //   margin-bottom: 44px;
}

/deep/ .van-nav-bar__title {
  font-size: 18px;
  color: #ffffff;
  letter-spacing: -0.6px;
  text-align: center;
}

/deep/ .van-nav-bar .van-icon {
  color: #fff;
  font-size: 20px;
}

/deep/ .van-tabs__line {
  width: 20px;
  margin-bottom: 3px;
}

/deep/ .van-tabs__nav--line {
  margin-bottom: 10px;
}

/deep/ .van-tab__text {
  font-size: 15px;
  color: #333333;
  letter-spacing: -0.53px;
}

/deep/ .van-radio-group {
  display: flex;
  justify-content: space-between;
  width: 180px;
}

/deep/ .van-panel__footer {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  padding: 0;
  z-index: 9;
}

/deep/ .van-button--default {
  background-color: #eee;
}

/deep/ .van-button {
  width: 100%;
  padding: 0;
}

/deep/ .van-radio__label--disabled {
  color: #999;
}

/deep/ .van-radio__icon--disabled.van-radio__icon--checked .van-icon {
  color: #41c2bf;
}

.ant-input-errors {
  border-color: #f5222d !important;
  border: 1px solid #f5222d !important;
}

.error-message {
  color: #f5222d;
  font-size: 14px;
  margin: 6px 0;
  transition: all 0.5s;
}
.showContent{
  margin: 30px 26px;
  text-align: center;
  .iconStyle{
    font-size: 50px;
    color: #20c51d;
  }
  .pcontent{
    font-size: 20px;
    font-weight: 500;
    color: #464646;
    margin: 10px 0;
  }
  .tipSuccess{
    color: #579de1;
  }
  .btnStyle{
    width: 40%;
  }
}
/deep/ .van-action-sheet__header{
  font-weight: 600;
}
.reasonRadio{
  /deep/ .van-radio-group {
    width: 100%;
    .van-cell-group {
      width: 99%;
      padding: 0 16px;
      .van-cell{
        height: 40px;
        line-height: 40px;
        color: #404040;
      }
    }
  }
}

</style>